package WaiBao;

import java.util.Arrays;

public class XuFangXu {
    public static void main(String[] args) {
        String[] name = {"李浩存(班长)", "刘宇星(团支书)", "小李(学习委员)", "李道村(纪律委员)", "陈赫", "吕子乔", "胡一菲", "张路远", "薛宝才", "熊黛玉", "刘姥姥", "吕布",
                "王一博", "肖战", "邓伦", "鹿晗", "王凯", "王子文", "卢文瀚", "王祖蓝", "王宝强", "刘昊然", "肖央", "罗奇缘", "李道华", "黄口度", "沙葱博", "戴天理",
                "杨幂", "许方旭(学生)"};//最后一位考生本人: 许方旭(学生)
        int[] age = {19, 21, 20, 20, 22, 21, 21, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 19, 19, 18, 19};//考生年龄：19岁

        double[] xiaopang1 = {84, 84, 95, 84, 91, 84, 74, 79, 84, 97, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 78, 74, 80, 96};
        double[] xiaopang2 = {78, 83, 85, 84, 96, 87, 71, 84, 94, 87, 94, 77, 76, 75, 65, 65, 86, 79, 66, 68, 92, 71, 95, 85, 75, 84, 79, 64, 90, 96};
        double[] xiaopang3 = {79, 84, 91, 91, 79, 66, 66, 77, 89, 80, 94, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 89, 95};

        double taozi;//代表每个学生的总分
        double xigua;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            taozi = xiaopang1[i] +xiaopang2[i] +xiaopang3[i];
//            xigua  = ( taozi* 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +  taozi);
//            System.out.println(name[i] + "的平均分为:" +  xigua);
//        }


        double caomei = 0, digua = 0;
        double[] heizi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            caomei = xiaopang1[i] +  xiaopang2[i] +  xiaopang3[i];
//            digua  = (caomei * 1.0) / 3;
//            heizi[i] = digua ;
//        }
//
//        for (int i = 0; i <heizi.length - 1; i++) {
//            for (int j = 0; j < heizi.length - i - 1; j++) {
//                if (heizi[j] < heizi[j + 1]) {
//                    double tep =heizi[j];
//                    heizi[j] =heizi[j + 1];
//                    heizi[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(heizi[i]);
//        }


        double xiaoxiao1 = 0, xiaoxiao2 = 0, xiaoxiao3 = 0;//计算每门课的平均分
        double xiaobai1 = 0,xiaobai2 = 0 ,xiaobai3 = 0;//计算每门课标准差
        double hami1 = 0,hami2 = 0,hami3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < xiaopang1.length; i++) {
            sum2+=xiaopang1[i];
        }
        xiaoxiao1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+xiaoxiao1);
        double Sum = 0;
        for (int i = 0; i < xiaopang2.length; i++) {
            Sum+=xiaopang2[i];
        }
        xiaoxiao2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+xiaoxiao2);
        double sum = 0;
        for (int i = 0; i <xiaopang3.length; i++) {
            sum+=xiaopang3[i];
        }
        xiaoxiao3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+ xiaoxiao3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < xiaopang1.length; i++) {
            c1+= (xiaopang1[i] - xiaoxiao1)*(xiaopang1[i] - xiaoxiao1);
        }
        xiaobai1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ xiaobai1);

        for (int i = 0; i <xiaopang2.length; i++) {
            c2+= (xiaopang2[i] - xiaoxiao2)*(xiaopang2[i] -xiaoxiao2);
        }
        xiaobai2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ xiaobai2);

        for (int i = 0; i < xiaopang3.length; i++) {
            c3+= (xiaopang3[i] -xiaoxiao3)*(xiaopang3[i] -xiaoxiao3);
        }
        xiaobai3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ xiaobai3);
////
////
//        Arrays.sort(xiaopang1);
//        Arrays.sort(xiaopang2);
//        Arrays.sort(xiaopang3);
//        hami1 =(xiaopang1[14]+xiaopang1[15])*1.0/2;
//        hami2 =(xiaopang2[14]+xiaopang2[15])*1.0/2;
//        hami3 =(xiaopang3[14]+xiaopang3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+hami1);
//        System.out.println("线性代数的中位数为:"+hami2);
//        System.out.println("有机化学的中位数为:"+hami3);

    }
}
